﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ShoppingApp2.BLL;
using ShoppingApp2.Common.Models;
using ShoppingApp2.Consts;

namespace ShoppingApp2.Controls
{
    public partial class CtrlRegister : System.Web.UI.UserControl
    {
        UsersBll _usersFcd;

        protected void Page_Load(object sender, EventArgs e)
        {
            _usersFcd = new UsersBll();
        }

        /// <summary>
        /// Event when register button clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // TODO: Implement
            _usersFcd.CreateUser(User);
        }

        /// <summary>
        /// Property for user in view
        /// </summary>
        public UserModelExt User
        {
            get
            {
                return new UserModelExt
                {
                    Email = this.txtEmail.Text.Trim(),
                    Nickname = this.txtNickname.Text.Trim(),
                    Password = this.txtPassword.Text.Trim(),
                    RoleId = (int)Roles.Standard,
                    Status = (int)UserStatus.Active
                };
            }
        }
    }
}